<template>
  <el-dialog
      :title="!dataForm.id ? '新增' : '修改'"
      :close-on-click-modal="false"
      fullscreen
      @close="formReset"
      :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
             label-width="140px">
      <el-row prop="productName" span="8">
        <el-col :span="12">
          <el-form-item label="样品编码" prop="productNumber">
            <el-select v-model="dataForm.productNumber" :disabled="dataForm.id != 0" placeholder="请选择" @change="getProductInfo">
              <el-option
                  v-for="item in productNumberOption"
                  :key="item.prProjectNumber"
                  :label="item.prProjectName"
                  :value="item.prProjectNumber">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="产品名称" prop="productName">
            <el-input v-model="dataForm.productName" placeholder="产品名称"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="产品型号" prop="productModeName">
            <el-input v-model="dataForm.productModeName" placeholder="产品型号名称"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="生产者名称" prop="producerName">
            <template>
              <el-select v-model="dataForm.productProducer" placeholder="请选择" @change="getEntrepreneurInfo">
                <el-option
                    v-for="item in entrepreneurOptions"
                    :key="item.id"
                    :label="item.name"
                    :value="item.name">
                </el-option>
              </el-select>
            </template>
          </el-form-item>
        </el-col>
<!--        <el-col :span="12">-->
<!--          <el-form-item label="生产者" prop="productProducer">-->
<!--            <el-input v-model="dataForm.productProducer" placeholder="生产者"></el-input>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--      </el-row>-->
<!--      <el-row label="产品型号" prop="model">-->
<!--        <el-col :span="12">-->
<!--          <el-form-item label="产品型号" prop="model">-->
<!--            <el-input v-model="dataForm.model" placeholder="产品型号"></el-input>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--      </el-row>-->
<!--      <el-row label="产品类型" prop="coveredModels">-->
<!--        <el-col :span="12">-->
<!--          <el-form-item label="产品类型" prop="coveredModels">-->
<!--            <el-input v-model="dataForm.coveredModels" placeholder="涵盖机型"></el-input>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--      </el-row>-->
<!--      <el-row label="生产者名称" prop="manufacturer">-->
<!--        <el-col :span="12">-->
<!--          <el-form-item label="生产者名称" prop="manufacturer">-->
<!--            <el-input v-model="dataForm.manufacturer" placeholder="生产者名称"></el-input>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--      </el-row>-->
<!--      <el-row label="生产者的注册地址" prop="manufacturerAddress">-->
        <el-col :span="12">
          <el-form-item label="生产者注册地址" prop="manufacturerAddress">
            <el-input v-model="dataForm.manufacturerAddress" placeholder="生产者的注册地址"></el-input>
          </el-form-item>
        </el-col>
<!--      </el-row>-->
<!--      <el-row label="生产者电话" prop="manufacturerPhone">-->
        <el-col :span="12">
          <el-form-item label="生产者电话" prop="manufacturerPhone">
            <el-input v-model="dataForm.manufacturerPhone" placeholder="生产者电话"></el-input>
          </el-form-item>
        </el-col>
<!--      </el-row>-->
<!--      <el-row label="生产者传真" prop="manufacturerFax">-->
        <el-col :span="12">
          <el-form-item label="生产者传真" prop="manufacturerFax">
            <el-input v-model="dataForm.manufacturerFax" placeholder="生产者传真"></el-input>
          </el-form-item>
        </el-col>
        <!--      </el-row>-->
        <!--      <el-row label="生产者联系人" prop="manufacturerContact">-->
        <el-col :span="12">
          <el-form-item label="生产者联系人" prop="manufacturerContact">
            <el-input v-model="dataForm.manufacturerContact" placeholder="生产者联系人"></el-input>
          </el-form-item>
        </el-col>
        <!--      </el-row>-->
        <!--      <el-row label="生产者邮政编码" prop="manufacturerContact">-->
        <el-col :span="12">
          <el-form-item label="生产者邮政编码" prop="manufacturerZipcode">
            <el-input v-model="dataForm.manufacturerZipcode" placeholder="生产者邮政编码"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="生产厂" prop="productManufacturingPlant">
            <template>
              <el-select v-model="dataForm.productManufacturingPlant" placeholder="请选择生产厂" @change="getProductionPlant">
                <el-option
                    v-for="item in entrepreneurOptions"
                    :key="item.id"
                    :label="item.name"
                    :value="item.name">
                </el-option>
              </el-select>
            </template>
          </el-form-item>
        </el-col>
<!--      </el-row>-->
<!--      <el-row label="生产厂名称" prop="factory">-->
<!--        <el-col :span="12">-->
<!--          <el-form-item label="生产厂名称" prop="factory">-->
<!--            <el-input v-model="dataForm.factory" placeholder="生产厂名称"></el-input>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--      </el-row>-->
<!--      <el-row label="生产厂的注册地址" prop="factoryAddress">-->
        <el-col :span="12">
          <el-form-item label="生产厂注册地址" prop="factoryAddress">
            <el-input v-model="dataForm.factoryAddress" placeholder="生产厂的注册地址"></el-input>
          </el-form-item>
        </el-col>

<!--      </el-row>-->
<!--      <el-row label="生产厂电话" prop="factoryAddress">-->
        <el-col :span="12">
          <el-form-item label="生产厂电话" prop="factoryPhone">
            <el-input v-model="dataForm.factoryPhone" placeholder="生产厂电话"></el-input>
          </el-form-item>
        </el-col>
<!--      </el-row>-->
<!--      <el-row label="生产厂传真" prop="factoryFax">-->
<!--        <el-col :span="12">-->
<!--          <el-form-item label="生产厂传真" prop="factoryFax">-->
<!--            <el-input v-model="dataForm.factoryFax" placeholder="生产厂传真"></el-input>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--      </el-row>-->
<!--      <el-row label="生产厂联系人" prop="factoryContact">-->
        <el-col :span="12">
          <el-form-item label="生产厂联系人" prop="factoryContact">
            <el-input v-model="dataForm.factoryContact" placeholder="生产厂联系人"></el-input>
          </el-form-item>
        </el-col>
<!--      </el-row>-->
<!--      <el-row label="生产厂邮政编码" prop="factoryContact">-->
<!--        <el-col :span="12">-->
<!--          <el-form-item label="生产厂邮政编码" prop="factoryZipcode">-->
<!--            <el-input v-model="dataForm.factoryZipcode" placeholder="生产厂邮政编码"></el-input>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
        <el-col :span="12">
          <el-form-item label="实际生产地址" prop="actualProductionAddress">
            <el-input v-model="dataForm.actualProductionAddress" placeholder="实际生产地址"></el-input>
          </el-form-item>
        </el-col>
<!--      </el-row>-->
<!--      <el-row label="鉴定依据的标准" prop="judgmentBasis">-->
        <el-col :span="12">
          <el-form-item label="鉴定依据的标准" prop="judgmentBasis">
            <el-input v-model="dataForm.judgmentBasis" placeholder="鉴定依据的标准"></el-input>
          </el-form-item>
        </el-col>
<!--      </el-row>-->
<!--      <el-row label="鉴定结论" prop="judgmentConclusion">-->
        <el-col :span="12">
          <el-form-item label="鉴定结论" prop="judgmentConclusion">
            <el-input v-model="dataForm.judgmentConclusion" placeholder="鉴定结论"></el-input>
          </el-form-item>
        </el-col>
<!--      </el-row>-->
<!--      <el-row label="鉴定报告的签发日期" prop="issueDate">-->
        <el-col :span="12">
          <el-form-item label="鉴定报告签发日期" prop="issueDate">
            <el-date-picker style="width: 135px"
                v-model="dataForm.issueDate"
                type="date"
                value-format="yyyy年MM月dd日"
                placeholder="选择日期时间">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="生产日期" prop="manufactureDate">
            <el-date-picker style="width: 135px"
              v-model="dataForm.manufactureDate"
              type="date"
              value-format="yyyy年MM月dd日"
              placeholder="选择日期时间">
            </el-date-picker>
          </el-form-item>
        </el-col>
<!--      </el-row>-->
<!--      <el-row label="样品图片(产品名称)" prop="pictureProductName">-->
        <el-col :span="12">
          <el-form-item label="样品图片(产品名称)" prop="pictureProductName">
            <file-upload :upload-url="uploadUrl + '/reportApproval/productinfo/fileUplod'" :value="dataForm.pictureProductName"
                         @change="(val) => dataForm.pictureProductName = val"
            ></file-upload>
<!--            <el-input v-model="dataForm.pictureProductName" placeholder="样品图片(产品名称)"></el-input>-->
          </el-form-item>
        </el-col>
<!--        <el-col :span="12">-->
<!--          <el-form-item label="样品图片(产品型号)" prop="pictureModel">-->
<!--            <file-upload upload-url="http://localhost:8088/reportApproval/productinfo/fileUplod" :value="dataForm.pictureModel"-->
<!--                         @change="(val) => dataForm.pictureModel = val"-->
<!--            ></file-upload>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
      </el-row>
<!--      <el-row>-->
<!--        <el-col :span="9">-->
<!--            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">-->
<!--              一致性检查（产品样机技术规格）-->
<!--            </span>-->
<!--        </el-col>-->
<!--      </el-row>-->
<!--      <el-row v-for="(item, indexs) in dataForm.proTecSpecVo" :key="indexs">-->
<!--        <el-col :span="12">-->
<!--          <el-form-item label="序号">-->
<!--            {{indexs + 1}}-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--        <el-col :span="10">-->
<!--          <el-form-item prop="projectName" label="项目">-->
<!--            <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--        <el-col :span="10">-->
<!--          <el-form-item prop="unit" label="单位">-->
<!--            <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--        <el-col :span="12">-->
<!--          <el-form-item prop="designValue" label="设计值">-->
<!--            <el-input type="text" placeholder="请输入设计值" v-model="item.designValue"/>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--        <el-col :offset="10" :span="4">-->
<!--          <el-form-item>-->
<!--            <el-button type="primary" v-if="dataForm.proTecSpecVo.length === indexs + 1" circle icon="el-icon-plus" @click="addItem(dataForm.proTecSpecVo)"></el-button>-->
<!--            <el-button v-if="indexs > 0" type="danger" circle icon="el-icon-minus" @click="delItem(dataForm.proTecSpecVo, indexs)"></el-button>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--      </el-row>-->
<!--      <el-row>-->
<!--        <el-col :span="24">-->
<!--            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">-->
<!--              涵盖机型（或同单元机型）样机技术规格-->
<!--            </span>-->
<!--        </el-col>-->
<!--      </el-row>-->
<!--      <el-row v-for="(item, index) in dataForm.proCoveredModelVo" :key="index">-->
<!--        <el-col :span="4">-->
<!--          <el-form-item label="序号">-->
<!--            {{index + 1}}-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--        <el-col :span="10">-->
<!--          <el-form-item prop="projectName" label="项目">-->
<!--            <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--        <el-col :span="10">-->
<!--          <el-form-item prop="unit" label="单位">-->
<!--            <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--        <el-col :span="12">-->
<!--          <el-form-item prop="designValue" label="设计值1">-->
<!--            <el-input type="text" placeholder="请输入设计值1" v-model="item.coverOne"/>-->
<!--          </el-form-item>-->
<!--        </el-col>-->

<!--        <el-col :span="12">-->
<!--          <el-form-item prop="designValue" label="设计值2">-->
<!--            <el-input type="text" placeholder="请输入设计值2" v-model="item.coverTwo"/>-->
<!--          </el-form-item>-->
<!--        </el-col>-->

<!--        <el-col :span="12">-->
<!--          <el-form-item prop="designValue" label="设计值3">-->
<!--            <el-input type="text" placeholder="请输入设计值3" v-model="item.coverThree"/>-->
<!--          </el-form-item>-->
<!--        </el-col>-->

<!--        <el-col :offset="10" :span="4">-->
<!--          <el-form-item>-->
<!--            <el-button type="primary" v-if="dataForm.proCoveredModelVo.length === index + 1" circle icon="el-icon-plus" @click="addItem(dataForm.proCoveredModelVo)"></el-button>-->
<!--            <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus" @click="delItem(dataForm.proCoveredModelVo, index)"></el-button>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--      </el-row>-->
<!--      <br/>-->
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确认</el-button>
    </span>
  </el-dialog>
</template>
<script>
import FileUpload from "@/components/FileUpload.vue";
import {httpBaseUrl} from "@/util/globa";

export default {
  components: {FileUpload},
  data() {
    return {
      visible: false,
      dataForm: {
        id: null,
        productNumber: null,
        productModeName:'',
        productProducer:'',
        productManufacturingPlant:'',
        productId: '',
        productName: '',
        model: '',
        coveredModels: '',
        manufacturer: '',
        manufacturerAddress: '',
        manufacturerPhone: '',
        manufacturerFax: '',
        manufacturerContact: '',
        manufacturerZipcode: '',
        factory: '',
        factoryAddress: '',
        factoryPhone: '',
        factoryFax: '',
        factoryContact: '',
        actualProductionAddress: '',
        factoryZipcode: '',
        judgmentBasis: '',
        judgmentConclusion: '',
        issueDate: '',
        manufactureDate: '',
        remark: '',
        reprotStatus: '',
        approver: '',
        approvalOpinion: '',
        auditor: '',
        auditOpinion: '',
        dateOfApproval: '',
        projectLeader: '',
        projectLeaderOpinion: '',
        projectLeaderDate: '',
        pictureProductName: '',
        pictureModel: '',
        remarks: '',
        reportWriter: '',
        reportDate: '',
        reportChecker: '',
        reportCheckerOpinion: '',
        reportCheckerDate: '',
        productFilePath: '',
        pdfPath: '',
        proCoveredModelVo: [{
          projectName: '',
          unit: '',
          coverOne: '',
          coverTwo: '',
          coverThree: '',
        }],
        proTecSpecVo: [{
          projectName: '',
          unit: '',
          designValue: '',
        }],
      },
      dataRule: {
        productId: [
          {required: true, message: '产品id不能为空', trigger: 'blur'}
        ],
        productName: [
          {required: true, message: '产品名称不能为空', trigger: 'blur'}
        ],
        model: [
          {required: true, message: '产品型号不能为空', trigger: 'blur'}
        ],
        coveredModels: [
          {required: true, message: '涵盖机型不能为空', trigger: 'blur'}
        ],
        manufacturer: [
          {required: true, message: '生产者名称不能为空', trigger: 'blur'}
        ],
        manufacturerAddress: [
          {required: true, message: '生产者的注册地址不能为空', trigger: 'blur'}
        ],
        manufacturerPhone: [
          {required: true, message: '生产者电话不能为空', trigger: 'blur'}
        ],
        manufacturerFax: [
          {required: true, message: '生产者传真不能为空', trigger: 'blur'}
        ],
        manufacturerContact: [
          {required: true, message: '生产者联系人不能为空', trigger: 'blur'}
        ],
        manufacturerZipcode: [
          {required: true, message: '生产者邮政编码不能为空', trigger: 'blur'}
        ],
        factory: [
          {required: true, message: '生产厂名称不能为空', trigger: 'blur'}
        ],
        factoryAddress: [
          {required: true, message: '生产厂的注册地址不能为空', trigger: 'blur'}
        ],
        factoryPhone: [
          {required: true, message: '生产厂电话不能为空', trigger: 'blur'}
        ],
        factoryFax: [
          {required: true, message: '生产厂传真不能为空', trigger: 'blur'}
        ],
        factoryContact: [
          {required: true, message: '生产厂联系人不能为空', trigger: 'blur'}
        ],
        factoryZipcode: [
          {required: true, message: '生产厂邮政编码不能为空', trigger: 'blur'}
        ],
        judgmentBasis: [
          {required: true, message: '鉴定依据的标准不能为空', trigger: 'blur'}
        ],
        judgmentConclusion: [
          {required: true, message: '鉴定结论不能为空', trigger: 'blur'}
        ],
        issueDate: [
          {required: true, message: '鉴定报告的签发日期不能为空', trigger: 'blur'}
        ],
        remark: [
          {required: true, message: '备注不能为空', trigger: 'blur'}
        ],
        reprotStatus: [
          {required: true, message: '报告状态不能为空', trigger: 'blur'}
        ],
        approver: [
          {required: true, message: '批准人不能为空', trigger: 'blur'}
        ],
        approvalOpinion: [
          {required: true, message: '批准人意见不能为空', trigger: 'blur'}
        ],
        auditor: [
          {required: true, message: '审核人不能为空', trigger: 'blur'}
        ],
        auditOpinion: [
          {required: true, message: '审核人意见不能为空', trigger: 'blur'}
        ],
        dateOfApproval: [
          {required: true, message: '审核日期不能为空', trigger: 'blur'}
        ],
        projectLeader: [
          {required: true, message: '项目负责人不能为空', trigger: 'blur'}
        ],
        projectLeaderOpinion: [
          {required: true, message: '项目负责人意见不能为空', trigger: 'blur'}
        ],
        projectLeaderDate: [
          {required: true, message: '项目负责人填写日期不能为空', trigger: 'blur'}
        ],
        pictureProductName: [
          {required: true, message: '样品图片(产品名称)不能为空', trigger: 'blur'}
        ],
        pictureModel: [
          {required: true, message: '样品图片(产品型号)不能为空', trigger: 'blur'}
        ],
        remarks: [
          {required: true, message: '备注信息不能为空', trigger: 'blur'}
        ],
        reportWriter: [
          {required: true, message: '报告编写人不能为空', trigger: 'blur'}
        ],
        reportDate: [
          {required: true, message: '报告编写日期不能为空', trigger: 'blur'}
        ],
        reportChecker: [
          {required: true, message: '报告校核人不能为空', trigger: 'blur'}
        ],
        reportCheckerOpinion: [
          {required: true, message: '报告校核意见不能为空', trigger: 'blur'}
        ],
        reportCheckerDate: [
          {required: true, message: '报告校核日期不能为空', trigger: 'blur'}
        ],
        productFilePath: [
          {required: true, message: '产品文件路径不能为空', trigger: 'blur'}
        ],
        pdfPath: [
          {required: true, message: 'pdf路径不能为空', trigger: 'blur'}
        ]
      },
      productNumberOption: [],
      entrepreneurOptions: [],
      uploadUrl: httpBaseUrl
    }
  },
  mounted() {
    this.getProductNumber();
    this.getEntrepreneurOptions();
  },
  methods: {
    getEntrepreneurOptions() {
      this.$http({
        url: this.$http.adornUrl('/reportapproval/entrepreneur/geteoptions'),
        method: 'get',
        data: this.$http.adornParams({})
      }).then((data) => {
        if (data && data.code === 0) {
          this.entrepreneurOptions = data.entrepreneurList;
        } else {
          this.$message.error(data.msg)
        }
      })
    },
    getProductionPlant(val) {
      this.$http({
        url: this.$http.adornUrl(`/reportapproval/entrepreneur/getCompanyNameInfo/${val}`),
        method: 'get',
        data: this.$http.adornParams({})
      }).then((data) => {
        if (data && data.code === 0) {
          this.dataForm.factoryAddress = data.entrepreneur.address
          this.dataForm.factoryPhone = data.entrepreneur.phone
          this.dataForm.factoryContact = data.entrepreneur.linkman;
          this.dataForm.actualProductionAddress = data.entrepreneur.actualProductionAddress;
        } else {
          this.$message.error(data.msg)
        }
      })
    },
    getEntrepreneurInfo(val) {
      this.$http({
        url: this.$http.adornUrl(`/reportapproval/entrepreneur/getCompanyNameInfo/${val}`),
        method: 'get',
        data: this.$http.adornParams({})
      }).then((data) => {
        if (data && data.code === 0) {
          this.dataForm.manufactoryName = data.entrepreneur.name
          this.dataForm.manufacturerAddress = data.entrepreneur.address
          this.dataForm.manufacturerPhone = data.entrepreneur.phone
          this.dataForm.manufacturerContact = data.entrepreneur.linkman;
          this.dataForm.manufacturerZipcode = data.entrepreneur.zipcode;
        } else {
          this.$message.error(data.msg)
        }
      })
    },
    getProductInfo(val) {
      this.$http({
        url: this.$http.adornUrl(`/reportapproval/product/getProductInfo/${val}`),
        method: 'get',
        data: this.$http.adornParams({})
      }).then((data) => {
        if (data && data.code === 0) {
          this.dataForm.productModeName = data.productInfo.prProducerModel;
          this.dataForm.productName = data.productInfo.prProjectName;
          this.dataForm.model = data.productInfo.prProducerModel;
          this.dataForm.coveredModels = data.productInfo.prProjectType;
          this.dataForm.judgmentBasis = data.productInfo.productExecutionText;
          this.dataForm.judgmentConclusion = `该机型一致性检查、安全性评价、适用性评价和可靠性评价符合${data.productInfo.productExecutionText}的要求，推广鉴定结论为通过。`;
        } else {
          this.$message.error(data.msg)
        }
      })
    },
    getProductNumber() {
      this.$http({
        url: this.$http.adornUrl('/reportapproval/product/getProjectNumber'),
        method: 'get',
        data: this.$http.adornParams({})
      }).then((data) => {
        if (data && data.code === 0) {
          this.productNumberOption = data.productList;
        } else {
          this.$message.error(data.msg)
        }
      })
    },
    formReset() {
      this.dataForm = {
        id: 0,
        productNumber: null,
        productModeName:'',
        productProducer:'',
        productManufacturingPlant:'',
        productId: '',
        productName: '',
        model: '',
        coveredModels: '',
        manufacturer: '',
        manufacturerAddress: '',
        manufacturerPhone: '',
        manufacturerFax: '',
        manufacturerContact: '',
        manufacturerZipcode: '',
        factory: '',
        factoryAddress: '',
        factoryPhone: '',
        factoryFax: '',
        factoryContact: '',
        factoryZipcode: '',
        judgmentBasis: '',
        judgmentConclusion: '',
        issueDate: '',
        manufactureDate: '',
        remark: '',
        reprotStatus: '',
        approver: '',
        approvalOpinion: '',
        auditor: '',
        auditOpinion: '',
        dateOfApproval: '',
        projectLeader: '',
        projectLeaderOpinion: '',
        projectLeaderDate: '',
        pictureProductName: '',
        pictureModel: '',
        remarks: '',
        reportWriter: '',
        reportDate: '',
        reportChecker: '',
        reportCheckerOpinion: '',
        reportCheckerDate: '',
        productFilePath: '',
        pdfPath: '',
        proCoveredModelVo: [{
          projectName: '',
          unit: '',
          coverOne: '',
          coverTwo: '',
          coverThree: '',
        }],
        proTecSpecVo: [{
          projectName: '',
          unit: '',
          designValue: '',
        }],
      };
    },
    addItem(array, value = {}) {
      array.push(value);
    },
    delItem(array, index) {
      array.splice(index, 1);
    },
    init(id) {
      this.dataForm.id = id || 0
      this.visible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].resetFields()
        if (this.dataForm.id) {
          this.$http({
            url: this.$http.adornUrl(`/reportApproval/productinfo/info/${this.dataForm.id}`),
            method: 'post',
            params: this.$http.adornParams()
          }).then((data) => {
            if (data && data.code === 0) {
              this.dataForm = data.productInfo;
            }
          })
        }
      })
    },
    // 表单提交
    save(){

    },
    dataFormSubmit() {
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          this.$http({
            url: this.$http.adornUrl(`/reportApproval/productinfo/${!this.dataForm.id ? 'save' : 'update'}`),
            method: 'post',
            data: this.$http.adornData(this.dataForm)
          }).then((data) => {
            if (data && data.code === 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.$refs['dataForm'].resetFields()
                  this.visible = false
                  this.$emit('refreshDataList')
                }
              })
            } else {
              this.$message.error(data.msg)
            }
          })
        }
      })
    }
  }
}
</script>
